#!/bin/tcsh

@ argv_num = $#argv

if ($argv_num < 4) then
echo
echo 'Usage: make_piv_set_folders.sh <location_dir> <set_name> <first#> <last#>'
echo 'for example:'
echo
echo '----------------------------------'
echo "make_piv_set_folders.sh . set 1 10"
echo '----------------------------------'
echo
echo 'will locally creat <set01> <set02> ... <set10>'
echo "with <BMP>, <IMG>, and <RESULTS> inside each <set*>."
echo 
endif

set loc = $argv[1]
set piv_set_name = $argv[2]
#set first_num = $argv[3]
#set last_num = $argv[4]

cd $loc

@ n = $argv[3]
echo $n
while ($n <= $argv[4])

if ($n < 10) then

mkdir {$piv_set_name}0{$n}
mkdir {$piv_set_name}0{$n}/BMP
mkdir {$piv_set_name}0{$n}/IMG
mkdir {$piv_set_name}0{$n}/RESULTS

echo "Data folder <"$piv_set_name"0"{$n}"> has been created."

else

mkdir $piv_set_name{$n}
mkdir $piv_set_name{$n}/BMP
mkdir $piv_set_name{$n}/IMG
mkdir $piv_set_name{$n}/RESULTS

echo "Data folder <"$piv_set_name{$n}"> has been created."
endif

@ n =($n + 1)
end
###---------- end of the script ----------
